package net.dgg.dggcloud.service.jrcrm.service.mq;

import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Envelope;
import net.dgg.dggcloud.service.entity.user.User;
import net.dgg.dggcloud.service.jrcrm.entity.business.Business;
import net.dgg.dggcloud.service.jrcrm.service.business.BusinessService;
import net.dgg.dggcloud.service.service.user.UserService;
import net.dgg.framework.tac.mq.rabbitmq.queue.normal.DggAbstractNormalConsumer;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.Date;
import java.util.Map;

/**
 * IBOSS上门消息处理
 *
 * @Title: DoorConsumer
 * @Description:
 * @Auther: 汤宏
 * @Date: 2018/11/19 9:15
 */
public class DoorConsumer extends DggAbstractNormalConsumer<String> {

    @Resource
    private UserService userService;
    @Resource
    private BusinessService businessService;



    public DoorConsumer() {
        this.queueName = "net.dgg.dggcloud.service.jrcrm.service.mq.doorQueue";
        this.hasDeadQueue = false;
    }

    public void setExchangeName(String exchangeName) {
        this.exchangeName = exchangeName;
    }


    @Override
    protected void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, String id) throws IOException {
   //     logger.info("IBOSS用户消息处理：{}" , data);
        try {
            if (StringUtils.isNotEmpty(id)) {
                businessService.mqSynchronousNotUpdateBusiness(id);
            }
        } catch (Exception e) {
            e.printStackTrace();
    //        logger.info("IBOSS用户消息处理异常：{}" ,data);
        }
    }
}
